<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtpagecontrol.inc.php");
use_unit("components4phpfull/jtiframe.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class SetupVehReminders2 extends Page
{
       public $imgNext = null;
       public $imgBack = null;
       public $btnVeh = null;
       public $Label1 = null;
       public $lblVeh = null;
       public $Image3 = null;
       public $hiddenStyle = null;
       public $JTFrameReminders = null;
       public $JTSiteTheme1 = null;
       public $hiddenVeh = null;
       function imgNextJSClick($sender, $params)
       {

       ?>
       //var answer = confirm("Proceed to next step?");
	     //if(answer)
       //{
		    window.location.href = "set_company_workorders.php";
		   //}
       <?php

       }
       function imgNextJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next.png';
       <?php

       }

       function imgNextJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgNext'].src = 'image/btn_next2.png';
       <?php

       }

       function imgBackJSClick($sender, $params)
       {

       ?>
       window.location.href = "set_template_list.php";

       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back1.png';
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgBack'].src = 'image/btn_back21.png';
       <?php

       }



       function btnNextJSClick($sender, $params)
       {

       ?>
       var answer = confirm("Proceed to next step?");
	     if(answer)
       {
		    window.location.href = "set_company_workorders.php";
		   }
       <?php

       }


       function btnVehJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var win_height = 450;
       var win_width = 600;
       var height = window.opener.outerHeight;
       var width = window.opener.outerWidth;
       var top = Math.round((height-win_height)/2);
       var left = Math.round((width-win_width)/2);
       window.open('set_select_vehicle_reminder.php','select_veh','location=no,height='+win_height+',width='+win_width+',top='+top+',left='+left);
       <?php

       }
       /*function JTPlatinumVehicleListShow($sender, $params)
       {
        $comp_id = $_SESSION['company_id'];
        $query1 = "select * from vehicle_tbl where company_id='".$comp_id."'";
        $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            $vehicle_id = $row['vehicle_id'];
            $veh_style = $row['style_name'];

            if($this->hiddenVeh->getValue()==$vehicle_id)
            $radio = "<a href=setup_vehicle_reminders.php?veh=".$vehicle_id."&style=".$veh_style."><img src='image/radio_select.png' border></a>";
            else
            $radio = "<a href=setup_vehicle_reminders.php?veh=".$vehicle_id."&style=".$veh_style."><img src='image/radio.png' border></a>";
            //$VIN = "<a href=vehicle_edit.php?veh=".$vehicle_id.">".$row['veh_num']."</a>";


            $arr[] = array(
                        'Plate Num' => $radio.'  '.$row['veh_num'],
                        'Year' => $row['year'],
                        'Make' => $row['manufacturer_name'],
                        'Model' => $row['model_name'],
                        'Style' => $row['style_name'],
                        'Operator' => $row['operator'],
                        'Department' => $row['department'],
                        );


          }

            $this->JTPlatinumVehicleList->setCellData($arr);



       }*/


       function SetupVehReminders2Create($sender, $params)
       {
       $comp_id = $_SESSION['company_id'];


       $result_veh = mysql_query("select * from vehicle_tbl where company_id='".$comp_id."' ORDER BY vehicle_id ASC LIMIT 1");
       $row_veh = mysql_fetch_array($result_veh);
       $veh = $row_veh['vehicle_id'];
       $style_id = $row_veh['style_id'];
       $veh_num = $row_veh['veh_num'];
       $this->hiddenVeh->setValue($veh);

       $this->hiddenStyle->setValue($style_id);
       $this->JTFrameReminders->setURL('set_veh_reminder_list.php?veh='.$this->hiddenVeh->getValue().'&style='.$this->hiddenStyle->getValue());
       //$this->imgBack->setLink('vehicle_list.php?company_id='.$_SESSION['company_id']);
       $this->lblVeh->Caption="<span style='color:white'>Vehicle:".$veh_num."</span>";

       $result_num = mysql_query("select * from vehicle_tbl where company_id='".$_SESSION['company_id']."'");
       $row_num = mysql_num_rows($result_num);

       if($row_num!=0)
       {
       if($veh==null || $veh=='')
        {
        $comp_id = $_SESSION['company_id'];
        $query_choose = "select * from vehicle_tbl where company_id='".$comp_id."' LIMIT 1";
        $result_choose = mysql_query($query_choose)or die(mysql_error());
        $row_choose = mysql_fetch_array($result_choose);
        $veh_id = $row_choose['vehicle_id'];

        /*$result_veh = ("select * from vehicle_tbl where vehicle_id='".$veh_id."'")or die(mysql_error());
        $row_veh = mysql_fetch_array($result_veh);

        $this->JTFrameReminders->setURL('veh_reminder_list.php?veh='.$veh_id.'&style='.$row_veh['style_name']);
        //die($query1);*/
        redirect('setup_vehicle_reminders.php?veh='.$veh_id);
        }


       }

      }

}

global $application;

global $SetupVehReminders2;

//Creates the form
$SetupVehReminders2=new SetupVehReminders2($application);

//Read from resource file
$SetupVehReminders2->loadResource(__FILE__);

//Shows the form
$SetupVehReminders2->show();

?>